package com.glory.hikvisionmobile.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.hikvisionmobile.R;
import com.glory.hikvisionmobile.bean.TrackOut.XSortingAndBoundsBean;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

public class PreWeldingListAdapter extends BaseQuickAdapter<XSortingAndBoundsBean, BaseViewHolder> {

    public PreWeldingListAdapter(@Nullable List<XSortingAndBoundsBean> data) {
        super(R.layout.adapter_pre_welding_list,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, XSortingAndBoundsBean item) {
        int adapterPosition = helper.getAdapterPosition();
        helper.setText(R.id.tvVirtualID,item.getWaferId());
        helper.setText(R.id.tvPrePosition,item.getCleanCarrierSeq());
        helper.setText(R.id.tvCarrierId,item.getReleaseCarrierId());
        helper.setText(R.id.tvAfterPosition,item.getReleaseCarrierSeq());
    }

    public JsonElement getJsonData() {
        if (getData() == null) {
            return new JsonArray();
        } else {
            Gson gson = new Gson();
            return gson.toJsonTree(getData(), new TypeToken<List<XSortingAndBoundsBean>>(){}.getType());
        }
    }
}
